<template>
  <el-menu
      class="el-menu-vertical-demo"
      background-color="var(--bg)"
      text-color="#fff"
      active-text-color="#ffd04b"
      unique-opened
      :default-active="CurrMenu"
      :collapse="IsCollapse"
      >
      <el-submenu :index="index.toString()" v-for="(item,index) in hasChildMenList" :key="item.name">
        <template slot="title">
          <i :class="item.icon"></i>
          <span>{{item.name}}</span>
        </template>

        <el-menu-item-group>
            <el-menu-item :index="citem.path" v-for="citem in item.children" :key="citem.name" @click="menuClick(citem)">
                
                <i :class="citem.icon"></i>
                {{citem.name}}
            </el-menu-item>
        </el-menu-item-group>
      </el-submenu>



       <el-menu-item :index="item.path" v-for="(item,index) in noneChildMenList" :key="item.name" @click="menuClick(item)">
        <i :class="item.icon"></i>
        <span slot="title">{{item.name}}</span>
      </el-menu-item>
    </el-menu>
</template>

<script>
export default {
data(){
    return{
        MenuList:[
            {
                name:'基础设置',
                icon:'el-icon-data-analysis',
                children:[
                    {
                        name:'计量单位',
                        path:'/MasterData/UnitMeasure',
                        icon:'el-icon-edit',
                    }
                ] 
            },
            {
                name:'人事管理',
                icon:'el-icon-notebook-2',
                children:[
                    {
                        name:'部门管理',
                        path:'/OA/Department',
                        icon:'el-icon-tickets'
                    },
                    {
                        name:'岗位管理',
                        path:'/OA/SystemPost',
                        icon:'el-icon-document-add'
                    },
                    {
                        name:'员工管理',
                        path:'/OA/Employees',
                        icon:'el-icon-document'
                    },
                    {
                        name:'请假申请',
                        path:'/OA/BpmOaLeave',
                        icon:'el-icon-document-remove'
                    },
                    {
                        name:'考勤管理',
                        path:'/OA/PlanShiftAttendance',
                        icon:'el-icon-s-order'
                    }
                ]   
            },
            {
                name:'产品管理',
                icon:'el-icon-s-order',
                children:[
                    {
                        name:'盘号',
                        path:'/Product/PanHao',
                        icon:'el-icon-caret-right'
                    },
                    {
                        name:'颜色',
                        path:'/Product/Color',
                        icon:'el-icon-orange'
                    },
                    {
                        name:'型号',
                        path:'/Product/Model',
                        icon:'el-icon-c-scale-to-original'
                    },
                    {
                        name:'规格',
                        path:'/Product/Spec',
                        icon:'el-icon-s-check'
                    },
                    {
                        name:'类别',
                        path:'/Product/ItemType',
                        icon:'el-icon-files'
                    },
                    {
                        name:'物料产品',
                        path:'/Product/Item',
                        icon:'el-icon-receiving'
                    }
                ] 
            },
            {
                name:'设备管理',
                icon:'el-icon-cpu',
                children:[
                    {
                        name:'设备类型',
                        path:'/Device/MachineryType',
                        icon:'el-icon-s-tools'
                    },
                    {
                        name:'设备状态',
                        path:'/Device/MachineryStatus',
                        icon:'el-icon-set-up'
                    },
                    {
                        name:'设备台账',
                        path:'/Device/Machinery',
                        icon:'el-icon-money'
                    }
                ] 
            },
            {
                name:'车间管理',
                icon:'el-icon-ship',
                children:[
                    {
                        name:'车间设置',
                        path:'/Works/Workshop',
                        icon:'el-icon-menu'
                    },
                    {
                        name:'工作站管理',
                        path:'/Works/Workstation',
                        icon:'el-icon-coordinate'
                    }
                ] 
            },
            {
                name:'工艺管理',
                icon:'el-icon-box',
                children:[
                    {
                        name:'工艺设置',
                        path:'/ProductProcess/ProProcess',
                        icon:'el-icon-coin'
                    },
                    {
                        name:'工艺流程',
                        path:'/ProductProcess/ProRoute',
                        icon:'el-icon-files'
                    }
                ] 
            },
            {
                name:'排班管理',
                icon:'el-icon-date',
                children:[
                    {
                        name:'班组类型',
                        path:'/Plans/TeamType',
                        icon:'el-icon-edit'
                    },
                    {
                        name:'班组设置',
                        path:'/Plans/Team',
                        icon:'el-icon-collection'
                    },
                    {
                        name:'排班计划',
                        path:'/Plans/PlanTeam',
                        icon:'el-icon-s-management'
                    },
                    {
                        name:'排班日历',
                        path:'/Plans/PlanCalendar',
                        icon:'el-icon-date'
                    }
                ] 
            },
            {
                name:'生产管理',
                icon:'el-icon-coin',
                children:[
                    {
                        name:'生产订单',
                        path:'/Productions/ProWorkorder',
                        icon:'el-icon-tickets'
                    },
                    {
                        name:'生产排产',
                        path:'/Productions/ProWorkScheduling',
                        icon:'el-icon-s-promotion'
                    },
                    {
                        name:'生产报工',
                        path:'/Productions/ProFeedback',
                        icon:'el-icon-mobile'
                    },
                    {
                        name:'生产任务',
                        path:'/Productions/ProTask',
                        icon:'el-icon-notebook-1'
                    },
                    {
                        name:'报工设备',
                        path:'/Productions/ProFeedbackEquipment',
                        icon:'el-icon-cpu'
                    },
                    {
                        name:'工时类型',
                        path:'/Productions/ProWorkhoursType',
                        icon:'el-icon-s-order'
                    },
                    {
                        name:'临时工时',
                        path:'/Productions/ProTemporaryWorkHours',
                        icon:'el-icon-time'
                    }
                ] 
            },
            {
                name:'检验标准',
                icon:'el-icon-s-platform',
                children:[
                    {
                        name:'检验方式',
                        path:'/Examine/QcWay',
                        icon:'el-icon-finished'
                    },
                    {
                        name:'检验器具',
                        path:'/Examine/QcProjectDevice',
                        icon:'el-icon-printer'
                    },
                    {
                        name:'检测项目分类',
                        path:'/Examine/QcProjectClassify',
                        icon:'el-icon-menu'
                    },
                    {
                        name:'检测项设置',
                        path:'/Examine/QcProject',
                        icon:'el-icon-s-tools'
                    },
                    {
                        name:'工序检测标准',
                        path:'/Examine/QcProcessStandard',
                        icon:'el-icon-document'
                    },
                    {
                        name:'常见缺陷',
                        path:'/Examine/QcProjectLevel',
                        icon:'el-icon-document'
                    }
                ] 
            },
            {
                name:'质量管理',
                icon:'el-icon-reading',
                children:[
                    {
                        name:'检验标准',
                        path:'/Examine/QcReceiveStandard',
                        icon:'el-icon-document-copy'
                    },
                    {
                        name:'来料检验',
                        path:'/Examine/QcReceiveRecord',
                        icon:'el-icon-document-copy'
                    },
                    {
                        name:'出货检验',
                        path:'/Examine',
                        icon:'el-icon-document-copy'
                    }
                ] 
            },
            {
                name:'工序检验',
                icon:'el-icon-reading',
                children:[
                    {
                        name:'检验单据',
                        path:'/ProcessExamine/QcProcessRecord',
                        icon:'el-icon-document-copy'
                    }
                ] 
            },
            {
                name:'往来单位',
                icon:'el-icon-user',
                children:[
                    {
                        name:'客户管理',
                        icon:'el-icon-user-solid',
                        path:'/Integrated/Client'
                    },
                    {
                        name:'供应商管理',
                        icon:'el-icon-s-custom',
                        path:'/Integrated/Vendor'
                    }
                ] 
            },
            {
                name:'销售管理',
                icon:'el-icon-finished',
                children:[
                    {
                        name:'物料价格',
                        path:'/SalesOrder/OrderSaleItemPrice',
                        icon:'el-icon-money'
                    },
                    {
                        name:'客户报价单',
                        path:'/SalesOrder/OrderQuote',
                        icon:'el-icon-document-checked'
                    },
                    {
                        name:'销售订单',
                        path:'/SalesOrder/OrderSale',
                        icon:'el-icon-tickets'
                    },
                    {
                        name:'销售出库',
                        path:'/SalesOrder/OrderSalesExWarehouse',
                        icon:'el-icon-takeaway-box'
                    },
                    {
                        name:'客户退货',
                        icon:'el-icon-receiving',
                        path:'/ReturnOrder/OrderReturn'
                    
                    }
                ] 
            },
            {
                name:'采购管理',
                icon:'el-icon-s-cooperation',
                children:[
                    {
                        name:'采购订单',
                        icon:'el-icon-s-cooperation',
                        path:'/PurchaseOrder/OrderPo'
                        
                    },
                    {
                        name:'到货通知',
                        icon:'el-icon-bell',
                        path:'/PurchaseOrder/WareHouseInboundBill'
                        
                    },
                    {
                        name:'采购入库',
                        icon:'el-icon-finished',
                        path:'/PurchaseOrder/WhPoInbound'
                        
                    },
                    {
                        name:'采购退货',
                        icon:'el-icon-s-ticket',
                        path:'/ReturnOrder/OrderPoReturn'
                        
                    }
                ]   
            },
            {
                name:'库存管理',
                icon:'el-icon-box',
                children:[
                    {
                        name:'生产领料',
                        path:'/Stock/OrderProductPick',
                        icon:'el-icon-ice-cream'
                    },
                    {
                        name:'生产退料',
                        path:'/Stock/OrderProductReceive',
                        icon:'el-icon-ice-cream'
                    },
                    {
                        name:'产品入库',
                        path:'/Stock/',
                        icon:'el-icon-document-add'
                    },
                    {
                        name:'仓库调拨',
                        path:'/Stock/WareHouseAllocation',
                        icon:'el-icon-document-add'
                    },
                    {
                        name:'其他入库',
                        path:'/Stock/OtherWareHouse',
                        icon:'el-icon-document-add'
                    },
                    {
                        name:'其他出库',
                        path:'/Stock/OtherExWareHouse',
                        icon:'el-icon-document-remove'
                    }
                ]   
            },
            {
                name:'库存查询',
                icon:'el-icon-s-cooperation',
                children:[
                    {
                        name:'库存查询',
                        path:'/Stock/ItemStock',
                        icon:'el-icon-document-remove'
                    },
                    {
                        name:'出库查询',
                        path:'/Stock/',
                        icon:'el-icon-document-checked'
                    },
                    {
                        name:'出入库统计',
                        path:'/Stock/OrderOutbound',
                        icon:'el-icon-document-copy'
                    },
                    {
                        name:'销售单统计',
                        path:'/Stock/',
                        icon:'el-icon-document'
                    },
                    {
                        name:'采购单统计',
                        path:'/Stock/',
                        icon:'el-icon-document'
                    }
                ]   
            },
            {
                name:'仓库管理',
                icon:'el-icon-box',
                children:[
                    {
                        name:'仓库',
                        path:'/StoreHouse/Warehouse',
                        icon:'el-icon-suitcase'
                    },
                    {
                        name:'库区',
                        path:'/StoreHouse/WmWarehouseArea',
                        icon:'el-icon-place'
                    },
                    {
                        name:'库位',
                        path:'/StoreHouse/WmWarehouseLocation',
                        icon:'el-icon-thumb'
                    }
                ]   
            },
            {
                name:'系统管理',
                icon:'el-icon-s-tools',
                children:[
                    {
                        name:'字典管理',
                        path:'',
                        icon:'el-icon-edit-outline'
                    },
                ]   
            }
        ]
    }
},
computed:{
        IsCollapse(){
            return this.$store.state.IsCollapse;
        },

        //智能选择当前左侧菜单
        CurrMenu(){
            if(this.$store.state.TabModel.TabList){
                let item = this.$store.state.TabModel.TabList.find(x=>x.active);
                if(item){
                    return item.path;
                }
            }
            return this.$store.state.TabModel.HomePath;
        },
        
        hasChildMenList(){
            return this.MenuList.filter(x=>x.children)
        },
        
        noneChildMenList(){
            return this.MenuList.filter(x=>!x.children)
        }
    },
    methods:{
        menuClick(item){
            this.$store.state.TabModel.CheckedTab(item);
        }
    }
}
</script>
